import microApp from '@/utils/microApp';
import GC from '@grapecity/spread-sheets';
import '@grapecity/spread-sheets-resources-zh';
import { Session } from '@/service/Session';
import router from 'umi/router';

export const qiankun = {
  // 应用加载之前
  async bootstrap(props = {}) {
    microApp.init(props.data);
  },
  // 应用 render 之前触发
  async mount(props) {
    try {
      GC.Spread.Common.CultureManager.culture('zh-cn');
    } catch (e) {
      console.log('汉化spreadjs失败。', e.message);
    }
    console.log('app mount,并汉化spreadjs', props);
    // eslint-disable-next-line no-restricted-globals
    router.replace(location.pathname + location.search);
    Session.getDefaultSettings();
  },
  // 应用卸载之后触发
  async unmount(props) {
    console.log('app unmount', props);
  },
};
